Whole year

msgpernickperweekday<- count(messages, unick ,format(datetime,"%A"))
names(msgpernickperweekday) <- c("unick","weekday","n")

msgpernickperweekday$weekday <- factor(msgpernickperweekday$weekday, levels = c("lundi","mardi","mercredi","jeudi","vendredi","samedi","dimanche"))


ggplot(data=msgpernickperweekday,aes(reorder(unick,n),n,fill=weekday)) + coord_flip() + geom_bar(stat="identity") + ggtitle(sprintf("Number of messages per weekday for %s", (yeartoload))) + xlab("Username") + ylab("# of messages") + scale_fill_brewer(palette = "Blues")

jColors <- usercolors$color 
 names(jColors) <- usercolors$unick



ggplot(data=scoreshgt,aes(reorder(unick,hgtscore),hgtscore)) + geom_bar(stat='identity') + coord_flip() + ylab("HGT Score") + xlab("Username")+ ggtitle("HGT Scores per username") + aes(fill=unick)+ scale_fill_manual(values = jColors)+ guides(fill=FALSE) 

msgpernickperhour<- count(messages, unick ,hour(datetime))
names(msgpernickperhour) <- c("unick","hour","n")
 


ggplot(data=msgpernickperhour, aes(x=hour,y=unick)) + geom_point(aes(size=n),pch=21) + aes(color=unick,fill=unick) + scale_fill_manual(values = jColors)+ ylab("# of messages") + ggtitle("Activity per hour for the whole year") + scale_x_continuous(breaks=1:24) + guides(color=FALSE,fill=FALSE)

msgperweekpernick <- count(messages, unick ,format(datetime,"%U"))
names(msgperweekpernick) <- c("unick","weeknumber","count")
ggplot(data=msgperweekpernick,aes(weeknumber,count,fill=unick)) + geom_bar(stat='identity')+ scale_fill_manual(values = jColors) + ggtitle("Number of messages per week & per nick") + xlab("Week Number") + ylab("Number of messages")

messages2 <- messages
messages2$msg <- as.numeric(nchar(messages2$msg))
messages2 <- messages2[,c(2,4)]
toplot <- aggregate(messages2$msg, by=list(messages2$unick), FUN="mean")
toplot <- toplot[,1:2]
names(toplot) <- c("Nick","averagecharpermsg")
ggplot(toplot,aes(x = Nick,y=averagecharpermsg)) + geom_bar(stat="identity") + coord_flip() + aes(fill=Nick) + scale_fill_manual(values = jColors) + guides(fill=FALSE) + ggtitle("Average number of chars per message") + xlab("Nick") + ylab("Average chars in message")

Word Cloud (2017) per nick

stopwordsFR <-as.character(read.csv("resources/stopwords-fr.txt", fileEncoding = "UTF-8", header=FALSE)$V1  )

search  = "çñÄÂÀÁäâàáËÊÈÉéèëêÏÎÌÍïîìíÖÔÒÓöôòóÜÛÙÚüûùúµ"
replace = "cnaaaaaaaeeeeeeeeeiiiiiiiioooooooouuuuuuuuu"





#loop on very unick
    for (unick in  unique(messages$unick)){
   msgClean <- messages[messages$unick==unick,]
   
   
   
   msgClean$msg <- tolower(chartr(search,replace,msgClean$msg))

msgClean$msg <- str_replace_all(msgClean$msg, "[^[:alnum:]]", " ")

temp <- (unlist(strsplit(msgClean$msg," ")))

"%w/o%" <- function(x, y) x[!x %in% y] #--  x without y

temp <- temp %w/o% stopwordsFR

temp <- temp[temp!= ""]

temp <- as.data.frame(table(temp))
temp$temp <- as.character(temp$temp)


temp <- temp[nchar(temp$temp) > 3,]

  cat("  \n###",  unick, "  \n")

  
  
   
  layout(matrix(c(1, 2),ncol = 2), widths = c(1, 10))
  par(mar=c(0,3,0,0))
  plot.new()
  
  
    wordcloud(temp$temp,temp$Freq,max.words =100, main="Title" , min.freq = 4
        , random.order = FALSE, rot.per=0.35, colors=brewer.pal(8, "Dark2"))
    
    text(x=0, y=0.5, unick, col=jColors[unick],cex=2,srt=90, font=2)
    
    cat("  \n")
    
    
    }

paf

logs

roux

lorent

vv

fesse

chaf

bz

aw

batto

gawel

letag

tony

maxba

natashaa

rylou

qn7o

woookash

notmika

nicrocolol

tux

mimoonet

mondayWeekMinus1 <- floor_date(Sys.Date()-7, "week")+1
sundayWeekMinus1 <- floor_date(Sys.Date(), "week")

##For test purposes - fake week-1
#mondayWeekMinus1 <- as.Date("2017-05-01")
#sundayWeekMinus1 <- as.Date("2017-05-07")

Previous week [2017-05-22 - 2017-05-28]

msgWEEK <- messages[messages$datetime >=mondayWeekMinus1 & messages$datetime <=  sundayWeekMinus1 ,]


msgpernickperhourWEEK <- count(msgWEEK, unick ,hour(datetime))

names(msgpernickperhourWEEK) <- c("unick","hour","n")


ggplot(data=msgpernickperhourWEEK, aes(x=hour,y=unick)) + geom_point(aes(size=n),pch=21) + aes(color=unick,fill=unick) + scale_fill_manual(values = jColors)+ ylab("# of messages") + ggtitle("Activity per hour of previous week")  + scale_x_continuous(breaks=1:24) + guides(color=FALSE,fill=FALSE)

msgpernickWEEKK <- count(msgWEEK, unick)


ggplot(data=msgpernickWEEKK,aes(reorder(unick,n),n)) + geom_bar(stat='identity') + coord_flip() + ylab("Number of messages") + xlab("Username")+ ggtitle("Most useless at work (previous week)") + aes(fill=unick)+ scale_fill_manual(values = jColors)+ guides(fill=FALSE)

Word Cloud (last week - top 500 - min 5 times)

msgWEEKClean <- msgWEEK
msgWEEKClean$msg <- tolower(chartr(search,replace,msgWEEKClean$msg))

msgWEEKClean$msg <- str_replace_all(msgWEEKClean$msg, "[^[:alnum:]]", " ")

temp <- (unlist(strsplit(msgWEEKClean$msg," ")))

"%w/o%" <- function(x, y) x[!x %in% y] #--  x without y

temp <- temp %w/o% stopwordsFR

temp <- temp[temp!= ""]

temp <- as.data.frame(table(temp))
temp$temp <- as.character(temp$temp)


temp <- temp[nchar(temp$temp) > 3,]



  wordcloud(temp$temp,temp$Freq,max.words =500 
        ,random.order=FALSE, rot.per=0.35, min.freq = 4,
          colors=brewer.pal(8, "Dark2"))

Last update: 2017-06-01 15:08:11

Last message in database : 2017-05-31 10:07:27